import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '楼栋',
    align:"center",
    dataIndex: 'buildId_dictText'
   },
   {
    title: '宿管人员',
    align:"center",
    dataIndex: 'managerName'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status',
    customRender:({text}) =>{
      return !text?"":(text=='0'?'停用':'启用')
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "楼栋",
      field: 'buildId',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dorm_build,build_name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "宿管人员",
      field: "managerName",
      component: 'Input',
      // componentProps: {
      //   labelKey: 'name',
      //   isRadioSelection: true
      // },
    // component: 'JPopup',
    // componentProps: ({ formActionType }) => {
    //     const {setFieldsValue} = formActionType;
    //     return{
    //         setFieldsValue:setFieldsValue,
    //         code:"select_person",
    //         fieldConfig: [
    //             { source: 'id', target: 'managerId' },
    //         ],
    //         multi:false
    //     }
    // },

      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '楼栋',
    field: 'buildId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"dorm_build,build_name,id",
        numberToString: true
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入楼栋!'},
          ];
     },
  },
  {
    label: '宿管人员',
    field: 'managerId',
    component: 'JSelectPerson',
    componentProps: {
      labelKey: 'name',
      isRadioSelection: true,
      showButtom: false,
    },
    // dynamicDisabled: ({ values }) => {
    //   return !!values.id;
    // },
    // component: 'JPopup',
    // componentProps: ({ formActionType }) => {
    //     const {setFieldsValue} = formActionType;
    //     return{
    //         setFieldsValue:setFieldsValue,
    //         code:"select_person",
    //         fieldConfig: [
    //             { source: 'id', target: 'managerId' },
    //         ],
    //         multi:false
    //     }
    // },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入宿管人员!'},
          ];
     },
  },
  {
    label: '状态',
    field:"status",
    component: 'JDictSelectTag',
    defaultValue:'1',
    componentProps:{
       options: [
        { label: '启用', value: '1' },
        { label: '停用', value: '0' },
       ],
     },
     dynamicRules: ({model,schema}) => {
           return [
                  { required: true, message: '状态不能为空!'},
           ];
      },
	  show: false
   },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  buildId: {title: '楼栋',order: 0,view: 'number', type: 'number',dictTable: 'dorm_build', dictCode: 'id', dictText: 'build_name',},
  managerId: {title: '宿管人员',order: 1,view: 'popup', type: 'string',code: 'select_person', orgFields: 'id', destFields: 'managerId', popupMulti: false,},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}